package com.hongding.sealcenter.response;


import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;

public abstract class ResponseUtil {

    private static final String SUCCESS = "SUCCESS";
    private static final String ERROR = "ERROR";

    public static ResponseEntity httpOk(){
        ApiResult result = new ApiResult();
        result.setSuccess(true);
        result.setMessage(SUCCESS);
        return ResponseEntity.ok(result);
    }

    public static ResponseEntity httpOk(String message){
        ApiResult result = new ApiResult();
        result.setSuccess(true);
        result.setMessage(message);
        return ResponseEntity.ok(result);
    }

    public static <T> ResponseEntity<ApiResult> httpOk(T body) {
        ApiResult result = new ApiResult();
        result.setData(body);
        result.setSuccess(true);
        result.setMessage(SUCCESS);
        return ResponseEntity.ok(result);
    }

    public static <T> ResponseEntity<ApiResult> httpOk(String message,T body) {
        ApiResult result = new ApiResult();
        result.setData(body);
        result.setSuccess(true);
        result.setMessage(message);
        return ResponseEntity.ok(result);
    }



    public static ResponseEntity<ApiResult> httpError() {
        ApiResult result = new ApiResult();
        result.setSuccess(false);
        result.setMessage(ERROR);
        return ResponseEntity.ok(result);
    }

    public static ResponseEntity<ApiResult> httpError(String message) {
        ApiResult result = new ApiResult();
        result.setSuccess(false);
        result.setMessage(message);
        return ResponseEntity.ok(result);
    }

    public static <T> ResponseEntity<ApiResult> httpError(T body) {
        ApiResult result = new ApiResult();
        result.setSuccess(false);
        result.setMessage(ERROR);
        result.setData(body);
        return ResponseEntity.ok(result);
    }

    public static  <T> ResponseEntity<ApiResult> httpError(String message,T body) {
        ApiResult result = new ApiResult();
        result.setSuccess(false);
        result.setMessage(message);
        result.setData(body);
        return ResponseEntity.ok(result);
    }
}

